package com.genius.smsdao.scoremanage.domain;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.genius.smsbase.Domain.BaseEntity;
import com.genius.smsdao.coursemanage.domain.Course;
import com.genius.smsdao.studentmanage.domain.Student;

import javax.persistence.*;

/**
 * @Entity:Score 成绩实体类
 * 对应数据库表名：score
 * @author：
 */
@Entity
@Table(name = "score")
public class Score extends BaseEntity<Long> {

    @Column
    private String name;
    @Column
    private Integer score;
    @Column
    private String remark;

    //成绩到成绩类型多对一关系
    @JsonIgnoreProperties("scoreList")
    @ManyToOne(targetEntity = ScoreKind.class,fetch = FetchType.EAGER)
    @JoinColumn(name = "score_kind_id",referencedColumnName = "id")
    private ScoreKind scoreKind;

    //成绩到学生多对一关系
    @JsonIgnoreProperties("scoreList")
    @ManyToOne(targetEntity = Student.class,fetch = FetchType.EAGER)
    @JoinColumn(name = "student_id",referencedColumnName = "id")
    private Student student;

    //成绩到课程多对一关系
    @JsonIgnoreProperties("scoreList")
    @ManyToOne(targetEntity = Course.class,fetch = FetchType.EAGER)
    @JoinColumn(name = "course_id",referencedColumnName = "id")
    private Course course;


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getScore() {
        return score;
    }

    public void setScore(Integer score) {
        this.score = score;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public ScoreKind getScoreKind() {
        return scoreKind;
    }

    public void setScoreKind(ScoreKind scoreKind) {
        this.scoreKind = scoreKind;
    }

    public Student getStudent() {
        return student;
    }

    public void setStudent(Student student) {
        this.student = student;
    }

    public Course getCourse() {
        return course;
    }

    public void setCourse(Course course) {
        this.course = course;
    }

    @Override
    public String toString() {
        return "Score{" +
                "name='" + name + '\'' +
                ", score=" + score +
                ", remark='" + remark + '\'' +
                ", scoreKind=" + scoreKind +
                ", student=" + student +
                ", course=" + course +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", id=" + id +
                '}';
    }
}
